using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Runtime.Serialization;
using System.Collections.Concurrent;
using System.ServiceModel;
using GZ.Modular.Log;
using GZ.Modular.Redis;
using GZ.Modular.Database;
using MongoDB.Driver;
using Dapper;
using System.Configuration;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using GZ.DB.Entity.wcs_hy;
using GZ.DB.IRepository.wcs_hy;
using GZ.DB.Repository.wcs_hy;
using GZ.Common.Data;
using Newtonsoft.Json;
using System.Security.Cryptography;
using System.Net;
using System.Threading;
using System.Globalization;
using System.IO.Ports;
using System.Drawing;
namespace GZ.Projects.WCS_YB
{
	#region 设备通信
	/// <summary>
	/// 设备通信
	/// </summary>
	public class Device
	{
		public GZ.Device.PLC.PlcBase TC01=null;
		public GZ.Device.PLC.PlcBase MEM=null;
		public GZ.Device.PLC.PlcBase CV01=null;
		public Device()
		{
			TC01 = GZ.Device.PLC.PlcFactory.CreateInstanceByFile
			(
				System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "TC01"),
				null,null,null
			);
			MEM = GZ.Device.PLC.PlcFactory.CreateInstanceByFile
			(
				System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "MEM"),
				null,null,null
			);
			CV01 = GZ.Device.PLC.PlcFactory.CreateInstanceByFile
			(
				System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "CV01"),
				null,null,null
			);
			if(System.Configuration.ConfigurationManager.AppSettings["AutoRunPLC"]=="1")
			{
				if(TC01!=null){TC01.Run();}
				if(MEM!=null){MEM.Run();}
				if(CV01!=null){CV01.Run();}
			}
        }
	}
	#endregion
	
	#region 简单PLC
		
	/// <summary>
	/// PLC变量组
	/// </summary>
	public class EasyPLC
	{
		#region TC01
		public _TC01 TC01 = new _TC01();
		/// <summary>
		/// 一号堆垛机
		/// </summary>		
		public class _TC01
		{
			public _StackerTaskExe StackerTaskExe = new _StackerTaskExe();
			/// <summary>
			/// 
			/// </summary>	
			public class _StackerTaskExe
			{
				public string wcs_taskExe = "";

				public bool Write()
				{
					return Write(null);
				}
				
				public bool Write(string logicNo)
				{
					return true;
				}
			}
			public _StackerFinishSend StackerFinishSend = new _StackerFinishSend();
			/// <summary>
			/// 
			/// </summary>	
			public class _StackerFinishSend
			{
				public string wcs_taskFinishAffirm = "";

				public bool Write()
				{
					return Write(null);
				}
				
				public bool Write(string logicNo)
				{
					return true;
				}
			}
			public _StackerAffirm StackerAffirm = new _StackerAffirm();
			/// <summary>
			/// 
			/// </summary>	
			public class _StackerAffirm
			{
				public string wcs_taskErrorAffirm = "";

				public bool Write()
				{
					return Write(null);
				}
				
				public bool Write(string logicNo)
				{
					return true;
				}
			}
			public _StackerReset StackerReset = new _StackerReset();
			/// <summary>
			/// 
			/// </summary>	
			public class _StackerReset
			{
				public string wcs_stReset = "";

				public bool Write()
				{
					return Write(null);
				}
				
				public bool Write(string logicNo)
				{
					return true;
				}
			}
			public _StackerStop StackerStop = new _StackerStop();
			/// <summary>
			/// 
			/// </summary>	
			public class _StackerStop
			{
				public string wcs_stStop = "";

				public bool Write()
				{
					return Write(null);
				}
				
				public bool Write(string logicNo)
				{
					return true;
				}
			}
			public _StackerTaskCancel StackerTaskCancel = new _StackerTaskCancel();
			/// <summary>
			/// 
			/// </summary>	
			public class _StackerTaskCancel
			{
				public string wcs_taskCancel = "";

				public bool Write()
				{
					return Write(null);
				}
				
				public bool Write(string logicNo)
				{
					return true;
				}
			}
			public _SendTaskOrder SendTaskOrder = new _SendTaskOrder();
			/// <summary>
			/// 
			/// </summary>	
			public class _SendTaskOrder
			{
				public string wcs_taskNo = "";

				public bool Write()
				{
					return Write(null);
				}
				
				public bool Write(string logicNo)
				{
					return true;
				}
			}
			public _SendTask SendTask = new _SendTask();
			/// <summary>
			/// 
			/// </summary>	
			public class _SendTask
			{
				public string wcs_taryType = "";
				public string wcs_startPosX = "";
				public string wcs_startPosY = "";
				public string wcs_startPosZ = "";
				public string wcs_endPosX = "";
				public string wcs_endPosY = "";
				public string wcs_endPosZ = "";
				public string wcs_taskType = "";

				public bool Write()
				{
					return Write(null);
				}
				
				public bool Write(string logicNo)
				{
					return true;
				}
			}
		}
		#endregion
		
		#region MEM
		public _MEM MEM = new _MEM();
		/// <summary>
		/// 记录mem的值
		/// </summary>		
		public class _MEM
		{
			public _TC01_INFO TC01_INFO = new _TC01_INFO();
			/// <summary>
			/// 
			/// </summary>	
			public class _TC01_INFO
			{
				public string TC01_LastTaskType = "";

				public bool Write()
				{
					return Write(null);
				}
				
				public bool Write(string logicNo)
				{
					return true;
				}
			}
		}
		#endregion
		
		#region CV01
		public _CV01 CV01 = new _CV01();
		/// <summary>
		/// 输送线部分
		/// </summary>		
		public class _CV01
		{
		}
		#endregion
		
	}

	#endregion
}